<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        p{
            text-align: center;
        }
        span{
            color: red;
        }
    </style>

</head>
<body>
    <p><span id="time">5</span>秒后,自动跳转到首页...</p>
    <script>
        var second = 5;
        function fun() {
            var ele = document.getElementById("time");
            second--;
            if(second <= 0){
                location.href = "https://www.baidu.com";
                clearInterval()
            }
            ele.innerHTML = second + "";
        }
        setInterval(fun, 1000);
    </script>
</body>
</html>